home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / DELPHI32 / GRIDS / MSTRGRID / MSTRGRID.TXT < prev    next >
Text File  |  1996-06-17  |  6KB  |  129 lines

  1. mStrGrid;
  2.  
  3. Version 1.0,  17.6.1996,  Freeware, Albrecht Mengel, mengel@stat-econ.uni-kiel.de
  4.  
  5. This is a component descending from TStringGrid with some new sorting and searching properties & methods:
  6.  
  7. procedure InsertCols(where,howmuch:Integer);
  8. procedure InsertRows(where,howmuch:Integer);
  9. procedure DeleteCols(where,howmuch:Integer);
  10. procedure DeleteRows(where,howmuch:Integer);
  11.    It does not matter if there are less rows/cols than you want to delete.
  12. procedure AddCol(contents:String;  delimiter:Char);
  13. procedure AddRow(contents:String;  delimiter:Char);
  14.    The contents are splitted into the single cells by the delimiter
  15. function ModifyRow(which:integer; contents,delimiter:string):integer;
  16.    Results in the number of columns
  17. function ModifyCol(which:integer; contents,delimiter:string):integer;
  18.    Results in the number of rows
  19.  
  20. The following properties control sorting and searching:
  21.  
  22. property KeyType:(soString,soStringCaseSensitive,soNumeric)
  23.    This is the kind, how the keys (and cells) are compared.
  24.    If you work with soNumeric, all non numbers get the same value 0.
  25.       As these zero values would flip in random order a (case insensitive) string sort
  26.       is performed after. So, first come the negatives, then the strings, and thereafter
  27.       the positives.
  28. property KeyPos:Integer;
  29. property KeyLen:Integer;
  30.    Here you may define, which substring of the cells is used to comparision.
  31.    (Default is KeyPos=1 & KeyLen=MaxInt)
  32. property UseFixed:(hfNot,hfSmart,hfYes);
  33.    hfNot: The fixed rows/columns remain as they are (and are not used in searching)
  34.    hfSmart: When sorting complete rows, the fixed columns are part of the rows and
  35.             change their contents in the same manner as the rows are exchanged.
  36.             The top row (fixed rows) remain intact.
  37.             When sorting complete columns, the fixed rows change and the fixed columns not.
  38.             When sorting (single) row/column, hfSmart protects the fixed part of the row/column.
  39.    hfYes: All sorting includes the fixed columns and rows (as if they were set to 0)
  40.  
  41. procedure SortCompleteColumns(KeyRow:integer);
  42. procedure SortCompleteRows(KeyCol:integer);
  43. procedure SortRow(ThisRow:integer);
  44. procedure SortCol(ThisCol:integer);
  45. procedure SortAllRows;
  46.    The rows are sorted independand
  47. procedure SortAllCols;
  48.    The columns are sorted independand
  49.  
  50. Searching can be done with the fixed substrings of cells
  51.    (set SearchSubstring=true and use KeyPos and KeyLen) or
  52.    anywhere in the cells (SearchSubstring=false)
  53. property SearchSubstring:Boolean;
  54.  
  55. function FindFirst(Key:String; RowWise:Boolean; VAR ResultCol,ResultRow:Integer):Boolean;
  56.     Searches all cells, if UseFixed=hfYes or excludes the fixed cells, if UseFixed=hfNo.
  57.     If UseFixed=hfSmart, then the fixed cols are used if searching rowwise or
  58.                               the fixed rows are used if not searching rowwise.
  59.     All finding methods result in true, when a cell was found.
  60.     If nothing found then ResultCol and ResultRow are set to -1.
  61. function FindFirstInRow(Key:String; searchRow:Integer; VAR ResultCol,ResultRow:Integer):Boolean;
  62.     The same as FindFirst, but only one row is used for searching.
  63.     UseFixed=hfSmart is here the same as hfNo.
  64. function FindFirstInCol(Key:String; searchCol:Integer; VAR ResultCol,ResultRow:Integer):Boolean;
  65. function FindNext(VAR ResultCol,ResultRow:Integer):Boolean;
  66.  
  67. A sample searching program:
  68.  if FindFirst('steven',true{rowwise},c,r) then
  69.  repeat memo1.lines.add('Found in cells['+inttostr(c)+','+inttostr(r)+'] = "'+cells[c,r]+'"');
  70.  until not FindNext(c,r);
  71.  
  72. File can be read to or written from the table as ASCII file.
  73. The second parameter is the column delimiter in every row.
  74.     procedure LoadFromFile(FileName,ColSep:string);
  75.     procedure SaveToFile(FileName,ColSep:String);
  76.  
  77. The demo program has one odd property: if found something in the fixed parts of the grid,
  78. the fixed rows/cols are duplicated. (Because it is not allowed to set the cursor there to)
  79.  
  80. The file mStrList is required for compilation.
  81. It contains a 'sister' of TStringList, which can sort in the above manner and is a complete copy
  82. of TStringList, which can be found in \source\vcl\GRIDS.PAS.
  83. But I had a problem with compiling it completely.
  84. If you are good in programming OOP / VCL then please have a look in mStrList.pas and
  85. help me fixing the problem. Until now all seems to work.
  86.  
  87. To install mStrGrid:
  88.  
  89. 1. Copy mStrGrid.* and mStrList.* to a directory for your special delphi components.
  90. 2. Select the Component: Install menu.
  91. 3. Click the Add button.
  92. 4. Click the Browse button.
  93. 5. Locate and select the mStrGrid.pas file
  94. 6. Click the Ok buttons to close all the dialogs.
  95. The Delphi component library DLL will be recompiled with the new mStrGrid component
  96. added to the Additional page of the component palette.
  97.  
  98. Software development:
  99.  
  100. Programming consumes time, and programmed components save time.
  101. If you like my components feel free to send me some acknowledgment.
  102. I accept post cards of your town, money or cheques (2$ up to 20$).
  103. This is a motivation for me to continue developing for you.
  104.  
  105. If you have some ideas to improve mStrList, mStrGrid or any other component
  106. send me a message.
  107.  
  108. The component is copyright (C) 1996, by Albrecht Mengel. You may give copies to
  109. others by copying the original, unmodified zip file. You may use this component
  110. in your own projects free of charge as long as those projects are public domain,
  111. freeware or shareware project.
  112.  
  113. The author of mStrList and mStrGrid (A. Mengel) makes no warranty of any kind,
  114. expressed or implied, including without limitation any warranties of merchantability
  115. and/or fitness for a particular purpose. In no event will the author be liable to you
  116. for any additional damages, including any lost profits, lost savings, or other
  117. incidental or consequential damages arising from the use of, or inability to use,
  118. this software and its accompanying documentation, even if the author has been advised
  119. of the possibility of such damages.
  120.  
  121. Albrecht Mengel, University of Kiel, Germany
  122. Institute for Statistics & Economics
  123. Olshausenstrasse 40-60,
  124. D-24098 Kiel
  125. Tel. +49-431-880-2424
  126. Fax. +49-431-880-2673
  127. Email: mengel@stat-econ.uni-kiel.de
  128. http://www.stat-econ.uni-kiel.de/pers/mengel.htm
  129.